home *** CD-ROM | disk | FTP | other *** search
- procedure findkeyword(start,stop:integer);
- var
- d, i:integer;
- begin
- i := start;
- while (GetPixel(i,0) <> 13) and (GetPixel(i,0) <> 10) and (i< stop) do i := i+1;
- while (GetPixel(i,0) <= 32) and (i < stop) do i := i+1;
- keyloc := i;
- end;
-
- procedure findvalue(start,stop:integer);
- var
- d, i, m:integer;
- begin
- i := start;
- while (GetPixel(i,0) <> 61) and (i < stop) do i := i+1;
- i := i+1;
- while (GetPixel(i,0) = 32) and (i < stop) do i := i+1;
- valloc := i;
- while (GetPixel(i,0) > 32) and (i < stop) do i := i+1;
- valend := i-1;
- end;
-
- procedure getint(start,stop:integer);
- var
- i,m:integer;
- begin
- m := 1;
- for i:= start to stop-1 do begin
- m:= m*10;
- end;
-
- value := 0;
- for i:= start to stop do begin
- d := GetPixel(i,0);
- if d=32 then d:=48;
- if (d<48) or (d>57) then
- begin
- PutMessage('This macro only reads PDS images with attached labels.');
- Dispose(nPics);
- exit;
- end;
- d:= d-48;
- value:=value+d*m;
- m:=m/10;
- end;
-
- end;
-
- macro 'Import PDS';
- {
- This macro will display PDS images with attached labels.
- }
- var
- width,height,offset,off,i,j,d,m,keyloc,valloc,valend,value:integer;
- begin
- width:=500;
- height:=1;
- off:=0;
- SetImport('8-bit');
- SetCustom(width,height,off);
- Import(''); {Read in header as an image, prompting for the file name.}
- {check to see if CCSD or NJPL or PDS otherwise quit}
- if ((GetPixel(0,0) = 67) and (GetPixel(1,0) = 67) and
- (GetPixel(2,0) = 83) and (GetPixel(3,0) = 68)) or
- ((GetPixel(0,0) = 78) and (GetPixel(1,0) = 74) and
- (GetPixel(2,0) = 80) and (GetPixel(3,0) = 76)) or
- ((GetPixel(0,0) = 80) and (GetPixel(1,0) = 68) and
- (GetPixel(2,0) = 83))
- then begin
- i:=0;
- end
- else begin
- PutMessage('This macro only reads PDS images.');
- Dispose(nPics);
- exit;
- end;
-
- {get the offset from the browse_image keyword}
- i := 0; j := 500; valloc := 1; keyloc := 0;
- findkeyword(i,j);
- repeat
- i := keyloc;
- if (GetPixel(i,0) = 94) and (GetPixel(i+1,0) = 66) and
- (GetPixel(i+2,0) = 82) and (GetPixel(i+3,0) = 79) and
- (GetPixel(i+4,0) = 87) and (GetPixel(i+8,0) = 73)
- then begin
- findvalue(i,j);
- end
- else begin
- i := i+1;
- findkeyword(i,j);
- end;
- until (valloc > 2) and (valloc < 499) or (keyloc >= 499);
- getint(valloc,valend);
- offset := value - 1;
-
- if (offset <= 0) then begin
- {get the offset from the image keyword }
- i := 0; j := 500; valloc := 1; keyloc:=0;
- findkeyword(i,j);
- repeat
- i := keyloc;
- if (GetPixel(i,0) = 94) and (GetPixel(i+1,0) = 73) and
- (GetPixel(i+2,0) = 77) and (GetPixel(i+6,0) <> 95)
- then begin
- findvalue(i,j);
- end
- else begin
- i := i+1;
- findkeyword(i,j);
- end;
- until (valloc > 2) and (valloc < 499) or (keyloc >= 499);
- {if the location contains non-numeric " or ' then print message does
- not work with detached labels.}
- getint(valloc,valend);
- offset := value - 1;
- end;
-
- off:=3900;
- Dispose(nPics);
- SetCustom(width,height,off);
- Import('');
-
- {get the width from the line_samples keyword }
- i:=0; j:=500; valloc:=1; keyloc:=0;
- findkeyword(i,j);
- repeat
- i := keyloc;
- if (GetPixel(i,0) = 76) and (GetPixel(i+1,0) = 73) and
- (GetPixel(i+2,0) = 78) and (GetPixel(i+5,0) = 83)
- then begin
- findvalue(i,j);
- end
- else begin
- findkeyword(i,j);
- end;
- until (valloc > 2) and (valloc < 499) or (keyloc >= 499);
- getint(valloc,valend);
- width := value;
-
- {get the height from the lines keyword }
- i:=0; j:=500; valloc:=1; keyloc:=0;
- findkeyword(i,j);
- repeat
- i := keyloc;
- if (GetPixel(i,0) = 76) and (GetPixel(i+1,0) = 73) and
- (GetPixel(i+2,0) = 78) and (GetPixel(i+4,0) = 83)
- then begin
- findvalue(i,j);
- end
- else begin
- i := i+1;
- findkeyword(i,j);
- end;
- until (valloc > 2) and (valloc < 499) or (keyloc >= 499);
- getint(valloc,valend);
- height := value;
-
- Dispose(nPics); {The ID of the last window opened is equal to nPics.}
- SetImport('8-bit');
- SetCustom(width,height,offset);
- Import(''); {No prompt this time; Import remembers the name.}
- end;
-